package com.powernode.lambda.stream;

import java.util.stream.Stream;

/**
 * 测试stream相关Api anyMatch、allMatch、noneMatch
 */
public class Stream06 {
    public static void main(String[] args) {
        Stream<Integer> stream = Stream.of(1, 2, 3, 4, 5, 6);

        //只有有一个元素是偶数，就返回ture
        //System.out.println(stream.anyMatch(x -> (x % 2) == 0));
        //当所有元素都是偶数，才返回ture
        //System.out.println(stream.allMatch(x -> (x % 2) == 0));
        //当所有元素都不是偶数，才返回ture
        System.out.println(stream.noneMatch(x -> (x % 2) == 0));
    }

}
